//
//  ShellRateViewModel.m
//  ShellWallert
//
//  Created by lvzhao on 2019/9/27.
//  Copyright © 2019年 VV. All rights reserved.
//

#import "ShellRateViewModel.h"
#import "ShellRateModel.h"

@implementation ShellRateViewModel

/**
 Convert 实时汇率
 @param  isFirst 是否是第一次
 */
- (void)getExchangeRates:(BOOL)isFirst{
    
    @weakify(self);
    [LZNetworkingManager lz_request:@"get" url:kLastestVersion params:nil success:^(id  _Nullable responseObject) {
         @strongify(self);
        
        if([responseObject[kResultStatus] isEqualToString:kCode]){
            NSArray *dataArray = responseObject[kResultData];
            
            for (int i = 0; i < dataArray.count; i++) {
                ShellRateModel *rateModel = [ShellRateModel mj_objectWithKeyValues:dataArray[i]];
                [self.dataArray addObject:rateModel];
            }
        }
        
       [self.reloadSubject sendNext:@(1)];

     } failure:^(NSError * _Nullable error) {
         
         [self.reloadSubject sendNext:@(1)];

     } notwork:^(NSError * _Nullable error) {
         
     } isLoading:YES isFailTip:YES];

}
@end
